<template>
	<view id="container">
		<!-- 我的认证信息 -->
		<view class="my-auth-box" style="background-image: url(../../../static/mine/my_auth.png);
		background-size: 100% 100%;" v-if="my_auth">
			<text style="font-weight: 600;">我的认证</text>
			<view class="name">
				<text style="font-weight: 500;margin-right: 10rpx;">认证主体:</text>
				<text>{{my_auth}}</text>
			</view>
			<view class="status">
				<text style="font-weight: 500;margin-right: 10rpx;">认证状态:</text>
				<text>{{auth_state}}</text>
			</view>
			<view class="status" v-if="cause">
				<text style="font-weight: 500;margin-right: 10rpx;">驳回原因:</text>
				<text>{{cause}}</text>
			</view>
			<view class="modify" v-if="state_code==1" @click="toCertificate">
				去修改
			</view>
		</view>
		<navigator url="./enterprise-certificate">
			<view class="enterprise-certificate">
				<image class="img" src="https://i.loli.net/2021/09/02/nrZ2TcV1qiDHfae.png" mode=""></image>
				<view class="btn">立即认证 ></view>
			</view>
		</navigator>
		<!-- 组织认证 -->
		<navigator url="./organization-certification">
			<view class="organization-certificate">
				<image class="img" src="https://i.loli.net/2021/09/02/i3wGpSCRFU5fvBz.png" mode=""></image>
				<view class="btn">立即认证 ></view>
			</view>
		</navigator>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				my_auth:'',
				auth_state:'',
				state_code: 0,
				cause: '',
				type: 0,
				id: 0
			};
		},
		
		onShow() {
			this.get_auth_detial()
		},
		methods:{
			// 获取用户的认证信息
			get_auth_detial(){
				let self = this
				this.$u.api.get_auth_detial().then(
				res=>{
					if(res.code==200){
						self.my_auth=res.data.firm;
						self.state_code=res.data.status;
						self.cause = res.data.cause;
						self.type = res.data.type;
						self.id = res.data.id;
						switch(self.state_code){
							case 0:
							self.auth_state='审核中...'
							break
							case 1:
							self.auth_state='请修改'
							break
							case 2:
							self.auth_state='已认证'
							break
						}
					}
				})
			},
			toCertificate() {
				if(this.type === 1) {
					// 企业
						uni.navigateTo({
								url: 'enterprise-certificate?id=' + this.id
						});
				} else if(this.type === 2) {
					// 组织
						uni.navigateTo({
								url: 'organization-certification?id=' + this.id
						});
				} else {
					return 
				}
			}
		}
	}
</script>

<style lang="scss">
	#container {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		
		.my-auth-box{
			margin-top: 10rpx;
			width: 615rpx;
			height: 320rpx;
			border: 2px solid #5989F9;
			border-radius: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: flex-start;
			padding: 54rpx 0 83rpx 64rpx;
			margin-top: 108rpx;
			position: relative;
			.modify{
				width: 148rpx;
				height: 42rpx;
				line-height: 42rpx;
				text-align: center;
				position: absolute;
				bottom: 26rpx;
				right: 38rpx;
				background-color: #5989F9;
				border-radius: 10rpx;
				font-weight: 800rpx;
				color: #FFFFFF;
				font-size: 24rpx;
			}
			
		}
		.img {
			width: 615rpx;
			height: 212rpx;
		}

		.btn {
			width: 148rpx;
			height: 42rpx;
			line-height: 42rpx;
			font-size: 24rpx;
			color: #fff;
			background: #5989F9;
			border-radius: 10rpx;
			position: absolute;
			right: 38rpx;
			bottom: 28rpx;
			text-align: center;
			letter-spacing: 5rpx;
			padding-left: 14rpx;
		}

		.personal-certificate {
			width: 615rpx;
			height: 212rpx;
			position: relative;
			margin: 82rpx auto;
		}

		.enterprise-certificate {
			width: 615rpx;
			height: 212rpx;
			position: relative;
			margin: 82rpx auto;

			.btn {
				background: #FBA754;
			}
		}

		.organization-certificate {
			width: 615rpx;
			height: 212rpx;
			position: relative;
			margin: 82rpx auto;

			.btn {
				background: #F9605F;
			}
		}
	}
</style>
